package com.creditease.rss.util;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

public class NetUtil {

	private NetUtil() {
	}

	public static boolean isNetworkAvailable(Context ctx) {

		ConnectivityManager manager = (ConnectivityManager) ctx
				.getSystemService(Context.CONNECTIVITY_SERVICE);

		if (manager == null) {
			return false;
		}
		NetworkInfo networkinfo = manager.getActiveNetworkInfo();
		if (networkinfo == null || !networkinfo.isAvailable() || !networkinfo.isConnectedOrConnecting()) {
			return false;
		}
		return true;
	}

	/**
	 * Description:
	 * 
	 * @param
	 * @return String
	 * @throws
	 * @Author liong Create Date: 2012-3-16 上午11:15:59
	 */

	public static String getFileNameByUrl(String urlStr) {
		String fileName = urlStr.replaceAll("/", "").replaceAll(":", "")
				.replaceAll("[.]", "").replaceAll("=", "")
				.replaceAll("[&]", "");
		return fileName;
	}
}
